Installation:

Place "backbutton" as a file with executable permissions (chmod 755 backbutton) in your path. I put it in my home folder, ~/bin/backbutton

Now, we need some aliases to make calling this easier.  Either run these, or better, run them automatically at startup.  I put these lines in ~/.profile

alias cd=". backbutton 1"
alias bk=". backbutton 2"
alias fw=". backbutton 3"

Functionality:

backbutton has three commands:

cd: Type cd exactly like you would use normal cd, where cd [filename] goes to filename's directory. \cd can be input to use the original cd.

bk: Goes back to the last page visited.  An optional argument is a number afterward, so bk 3 would take you 3 steps backward.

fw: Takes you forward a page if you've gone backward previously.  Optionally, type a number afterward, like fw 2, to go fw 2 pages.